//
//  HSHomeworkController.swift
//  HomeSchoolDemo
//
//  Created by Mac on 16/9/26.
//  Copyright © 2016年 chendong. All rights reserved.
//

import UIKit

class HSHomeworkController: HSBasicController {
    
    let homeworklist = HSHomeworkListModel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //注册原形cell
        tableView.register(UINib(nibName: "HSHomeworkCell", bundle: nil), forCellReuseIdentifier: "homeworkCell")
        tableView.rowHeight = 77
        loadData()
    }
    
    override func loadData() {
        //开启刷新控件
        refrshC.beginRefreshing()
        homeworklist.requestHomework()
        refrshC.endRefreshing()
        tableView.reloadData()
    }
    
}

//代理方法
extension HSHomeworkController{
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        
        return homeworklist.homeworks.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "homeworkCell", for: indexPath) as! HSHomeworkCell
        let homework = homeworklist.homeworks[indexPath.row]
        cell.homeworkVM = homework
        return cell
    }
    
}
